require 'socket'

server = Socket.new :INET,:STREAM
addr = Socket.pack_sockaddr_in(4481,'0.0.0.0')

server.bind(addr)
server.listen(128)

conn ,_ = server.accept

print 'Connection class:'
p conn.class

print 'Server fo:'
p server.fileno

print 'Connection fo:'
p conn.fileno

print 'Local addr:'
p conn.local_address

print 'Remote addr:'
p conn.remote_address

# 测试命令
# echo ohai | nc 127.0.0.1 4481

# /home/zd/.rvm/rubies/ruby-2.4.1/bin/ruby -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /home/zd/zd04/tcpSockets/snippets/accept_connetion_class.rb
# Connection class:Socket
# Server fo:7
# Connection fo:8
# Local addr:#<Addrinfo: 127.0.0.1:4481 TCP>
#           Remote addr:#<Addrinfo: 127.0.0.1:40368 TCP>
#
#     Process finished with exit code 0